#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn = 100005;
int n,m;
bool inq[maxn];

struct node{
	int left;
	int right;
}point[maxn];


int main(){
	cin>>n;
	inq[1]=true;
	int k,p;
	int head=1;
	for(int i=2;i<=n;i++){
		cin>>k>>p;
		if(p==0){
			//a i k c
			inq[i]=true;
			point[i].left=point[k].left;
			point[i].right=k;
			point[point[k].left].right=i;
			point[k].left=i;
			if(point[i].left==0)head=i;
		}else{
			//a k i c
			inq[i]=true;
			point[i].right=point[k].right;
			point[i].left=k;
			point[point[k].right].left=i;
			point[k].right=i;
		}
	}
	
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>k;
		if(inq[k]){
			//a k b
			inq[k]=false;
			if(k==head)head=point[k].right;
			point[point[k].left].right=point[k].right;
			point[point[k].right].left=point[k].left;
		}else	continue;
	}
	int i=head;
	for(i;point[i].right!=0;i=point[i].right){
		cout<<i<<" ";
	}
	cout<<i<<endl;
	return 0;
}